package com.acwing.partition12;

import java.io.*;

/**
 * @author `RKC`
 * @date 2021/12/31 10:46
 */
public class AC1116马走日 {

    private static final int N = 10, M = 10;
    private static int n = 0, m = 0, startX = 0, startY = 0, ans = 0;
    private static boolean[][] visited = new boolean[N][M];
    private static final int[][] dirs = {{-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2}, {-1, -2}, {-2, -1}};

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        int k = Integer.parseInt(reader.readLine());
        while (k-- > 0) {
            String[] s = reader.readLine().split("\\s+");
            n = Integer.parseInt(s[0]);
            m = Integer.parseInt(s[1]);
            startX = Integer.parseInt(s[2]);
            startY = Integer.parseInt(s[3]);
            ans = 0;
            dfs(startX, startY, 1);
            writer.write(ans + "\n");
        }
        writer.flush();
    }

    private static void dfs(int x, int y, int count) {
        if (count == n * m) {
            ans++;
            return;
        }
        visited[x][y] = true;
        for (int[] dir : dirs) {
            int a = dir[0] + x, b = dir[1] + y;
            if (a < 0 || a >= n || b < 0 || b >= m || visited[a][b]) continue;
            dfs(a, b, count + 1);
        }
        visited[x][y] = false;
    }
}
